<?php
/**
 * Created by PhpStorm.
 * User: Deann.wu
 * Date: 2018/3/19 0019
 * Time: 19:53
 */
namespace App\Http\Controllers\Home;
use App\Http\Controllers\Controller;
use App\Models\Post;
use App\Models\Types;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
use Qiniu\Http\Client;

class LifeController extends Controller{

    public function __construct()
    {
        parent::__construct();
        //标签
        View::share('keyword','');
        //标题
        View::share('title','生活记录');
    }

    /**
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * @author Deann.wu
     * @name 所有内容数据
     * @description
     *   生活记录的分类id是 4
     */
    public function lifeList(){
        //模块阐述
        $this->modelElaborate('生活记录','我想知道你走了多远的路，才能把过去留在身后。','记录列表','/home/images/main-sh.png');
        //所有子分类数据
        $sons=Types::getDataBySonList(4);
        //将数据id读入到一个数组中
        $sons_ar=array();
        foreach ($sons as $son){
            if(!empty($son)){
                $sons_ar[]=$son->id;
            }
        }
        //筛选数据
        $lists=Post::getListAllBySon($sons_ar);
        return view('home.life.list',compact('lists'));
    }

}